package com.gisocn.onemap.ui.fragment;

import android.os.Bundle;
import android.text.TextUtils;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.EditText;
import android.widget.TextView;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import butterknife.Unbinder;
import com.gisocn.onemap.base.BaseFragment;
import com.gisocn.onemap.model.ChangeUserPassword;
import com.gisocn.onemap.presenter.ChangePassWordPresent;
import com.gisocn.onemap.sgzx.R;
import com.gisocn.onemap.utils.SpUtils;
import com.gisocn.onemap.view.ChangePassWordView;
import java.util.HashMap;

/* loaded from: classes2.dex */
public class ChangePassWordFragment extends BaseFragment<ChangePassWordPresent> implements ChangePassWordView {
    @BindView(R.id.et_confirm_password)
    EditText etConfirmPassword;
    @BindView(R.id.et_new_password)
    EditText etNewPassword;
    @BindView(R.id.et_old_password)
    EditText etOldPassword;
    ChangePassWordPresent passWordPresent;
    @BindView(R.id.tv_close)
    TextView tvClose;
    @BindView(R.id.tv_title)
    TextView tvTitle;
    Unbinder unbinder;
    private String userId;

    @Override // com.gisocn.onemap.base.BaseFragment
    protected void onInvisible() {
    }

    @Override // com.gisocn.onemap.base.BaseFragment, androidx.fragment.app.Fragment
    public View onCreateView(LayoutInflater layoutInflater, ViewGroup viewGroup, Bundle bundle) {
        View inflate = layoutInflater.inflate(R.layout.fragment_chanage_password, viewGroup, false);
        this.unbinder = ButterKnife.bind(this, inflate);
        return inflate;
    }

    @Override // com.gisocn.onemap.base.BaseFragment
    protected void initData() {
        this.tvTitle.setText(R.string.change_password);
        this.passWordPresent = createPresenter();
        if (SpUtils.get(getActivity(), "userId", "") != null) {
            String obj = SpUtils.get(getActivity(), "userId", "").toString();
            this.userId = obj;
            Log.e("userId", obj);
        }
    }

    /* JADX INFO: Access modifiers changed from: protected */
    @Override // com.gisocn.onemap.base.BaseFragment
    public ChangePassWordPresent createPresenter() {
        return new ChangePassWordPresent(this);
    }

    @Override // com.gisocn.onemap.base.BaseFragment, androidx.fragment.app.Fragment
    public void onDestroyView() {
        super.onDestroyView();
        this.unbinder.unbind();
    }

    @OnClick({R.id.tv_close, R.id.btn_change_password})
    public void onViewClicked(View view) {
        int id = view.getId();
        if (id != R.id.btn_change_password) {
            if (id != R.id.tv_close) {
                return;
            }
            getActivity().findViewById(R.id.viewPager).setVisibility(8);
        } else if (!TextUtils.isEmpty(getStr(this.etOldPassword))) {
            if (!TextUtils.isEmpty(getStr(this.etNewPassword))) {
                if (!TextUtils.isEmpty(getStr(this.etConfirmPassword))) {
                    if (getStr(this.etNewPassword).equals(getStr(this.etConfirmPassword))) {
                        HashMap hashMap = new HashMap();
                        hashMap.put("userId", this.userId);
                        hashMap.put("pwd", getStr(this.etOldPassword).trim());
                        hashMap.put("newPwd", getStr(this.etNewPassword).trim());
                        this.passWordPresent.chanagePassWord(hashMap);
                        return;
                    }
                    showToast("2次输入的密码不一致!");
                    return;
                }
                showToast("确认密码不能为空!");
                return;
            }
            showToast("新密码不能为空!");
        } else {
            showToast("旧密码不能为空!");
        }
    }

    @Override // com.gisocn.onemap.view.ChangePassWordView
    public void success(ChangeUserPassword changeUserPassword) {
        showToast("修改密码成功!");
        getActivity().findViewById(R.id.viewPager).setVisibility(8);
    }

    @Override // com.gisocn.onemap.view.ChangePassWordView
    public void fail(String str) {
        showToast(str);
    }
}
